﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" Title="Untitled Page" CodeBehind="Login.aspx.cs" %>

<script runat="server">

    protected void ButtonConnexion_Click(object sender, EventArgs e)
    {
        String email = Convert.ToString(TextBoxEmail.Text);
        String passwd = Convert.ToString(TextBoxPswd.Text);
        EventHandler LoggedIn;
        var c = INSTA.MusiqueStore.DAL.ConnectionCustomer.Connection(email, passwd);
        if (c == null)
        {
            Response.Redirect("~/Account/FalseLogin.aspx");
            Session["test"] = false;

        }

        else
        {
            //Response.BufferOutput = true;
            Session["UserConnecté"] = c.Email;
            Session["idClient"] = c.Id;
            FormsAuthentication.RedirectFromLoginPage(email, true);

            //Response.Redirect("~/Account/WelcomCustomers.aspx");
            Session["test"] = true;
            Session["UserConnecté"] = email;
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">

    <div class="divContenu">
        <div class="accountHeader">
            <h2>Connexion</h2>
            <br />
            <p>
                <span>Rentrer votre mot de passe</span>. <a href="~/Account/SendPassword.aspx">Mot de passe oublié</a>. 
           <br />
                <br />
                <form method="POST" action="~/Default.aspx">

                    <table style="width: 100%;">
                        <tr>
                            <td class="auto-style2">
                                <dx:ASPxLabel ID="LabelEmail" runat="server" Text="Email" />
                                <dx:ASPxTextBox ID="TextBoxEmail" runat="server" Width="200px">
                                </dx:ASPxTextBox>

                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBoxEmail"
                                    Display="Dynamic" ValidationGroup="newUser"
                                    ErrorMessage="Email invalide veuillez vérifier la saisie de votre e-mail"
                                    ValidationExpression="^[a-zA-Z0-9-+.'_]+@\w+([-.]\w+)*\.\w+([-.]\w+)*$" />



                            </td>

                        </tr>
                        <tr>
                            <td>
                                <dx:ASPxLabel ID="LabelPswd" runat="server" Text="Mot de Passe" />
                                <dx:ASPxTextBox ID="TextBoxPswd" runat="server" Width="200px" Password="True">
                                </dx:ASPxTextBox>
                            </td>

                        </tr>
                        <tr>
                            <td>
                                <dx:ASPxButton ID="ButtonConnexion" runat="server" Text="Valider" OnClick="ButtonConnexion_Click">
                                </dx:ASPxButton>
                            </td>

                        </tr>
                    </table>

                </form>
        </div>
    </div>
</asp:Content>



